<script>
	import {LoginApi} from '@/api/user/LoginApi'
	export default {
		onLaunch: function(e) {
			let that = this
			// #ifdef H5
			if(that.$Common.isWechat()){
				let code = e.query.code
				if (!code) {
				    window.open("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + that.$Dict.config.wxMpAppId + "&redirect_uri=" + encodeURIComponent(location.href) + "&response_type=code&scope=snsapi_userinfo#wechat_redirect");
				} else {
				    LoginApi.wxLogin(code).then((response) => {
				        if (response.code === -3) {
							that.$Auth.setWxOpenId(response.data)
				        } else {
				            that.$Auth.setToken(response)
				            that.$store.dispatch('user/getInfo').then(() => {
				            })
				        }
				    })
				}
			}
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
/*每个页面公共css */
@import "./static/style/iconfont/iconfont.css";
//@import "https://at.alicdn.com/t/c/font_4286917_q1kcn8axv49.css";

view{ color:#232323; font-size: 32rpx; box-sizing: border-box;}
span{font-size: inherit;}
page{background-color: #f8f8f8; box-sizing: border-box;}
uni-list{display: block;}

.uni-container {padding: 30rpx;}
.uni-word1{padding-left:0.5em;}
.uni-word2{padding-left:1em;}
.uni-word4{padding-left:2em;}
.uni-btn{height:80rpx; line-height:80rpx; text-align:center; background:$uni-global-color; border:none;
    font-size:32rpx; display:block; color:#FFF; border-radius: 40rpx;}
.uni-btn:hover,.uni-btn:active,.uni-btn:link{color:#FFF;}
.uni-flex{display: flex;}
.uni-center{align-items: center;}
</style>
